﻿using System.Linq.Expressions;
using System.Reflection;
using CoreEx.Database.Metadata;

namespace CoreEx.Database.Linq
{
    /// <summary>
    /// Describes a relation to be load along with the target type.
    /// </summary>
    public interface IRelationLoadTarget
    {
        /// <summary>
        /// Gets or sets the target property for this <see cref="IRelationLoadTarget"/>
        /// </summary>
        PropertyInfo TargetProperty { get; set; }

        /// <summary>
        /// Gets or sets a <see cref="bool"/> values that indicates if the relation 
        /// described by this <see cref="IRelationLoadTarget"/> has been loaded.
        /// </summary>
        bool IsLoaded { get; set; }

        /// <summary>
        /// Gets or sets the <see cref="LambdaExpression"/> that describes the member to be loaded.        
        /// </summary>
        /// <remarks>
        /// The <see cref="LambdaExpression"/> may contain a <see cref="MethodCallExpression"/> for 
        /// enumerable load targets.        
        /// </remarks>
        LambdaExpression LoadExpression { get; set; }

        /// <summary>
        /// Gets or sets the <see cref="IPropertyMappingInfo"/> instance that applies to the <see cref="TargetProperty"/>.
        /// </summary>
        IPropertyMappingInfo PropertyMapping { get; set; }
    }
}
